#FROM openjdk:8-jdk-alpine
#ADD ./target/preview.jar preview.jar
#ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","preview.jar"]
#EXPOSE 5001

# 注: 分层创建 docker 镜像, 会生成两个镜像, 一个 none 需要在创建完成之后删除
# docker rmi $(docker images --filter dangling=true -q)

FROM openjdk:8-jdk-alpine as builder
WORKDIR application
ARG JAR_FILR=target/*.jar
ADD ${JAR_FILR} application.jar
RUN java -Djarmode=layertools -jar application.jar extract

FROM openjdk:8-jdk-alpine
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
EXPOSE 5001

#ENV TZ="Asia/Shanghai"
#RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
#ENV JVM_OPTS="-XX:MaxRAMPercentage=80.0"
#ENV JAVA_OPTS=""
#ENTRYPOINT ["sh","-c","java $JVM_OPTS $JAVA_OPTS org.springframework.boot.loader.JarLauncher"]
